package com.hd123.rumba.gwt.widget.client.codenamebox;

import com.google.gwt.user.client.rpc.AsyncCallback;
import com.hd123.rumba.gwt.widget.client.grid.DxGridDataProvider;
import com.hd123.rumba.gwt.widget.client.grid.PageDataProvider;

public abstract class CNBBrowserDataProvider extends PageDataProvider implements DxGridDataProvider {
  protected CNBFilter filter = null;

  public void setFilter(CNBFilter filter) {
    this.filter = filter;
    setNeedFetch(true);
  }

  public CNBFilter getFilter() {
    return filter;
  }

  public abstract void doFetch(int page, AsyncCallback callback);

  public int getColumnCount() {
    return 2;
  }

  public String getData(int row, int col) {
    if (row >= getRowCount())
      return " ";
    UuidCodeName vo = (UuidCodeName) getValues().get(row);
    switch (col) {
    case 0:
      return vo.getCode();
    case 1:
      if (vo.getExtra() == null)
        return vo.getName();
      else
        return vo.getName() + "," + vo.getExtra();
    }
    return "";
  }
}
